package com.rocksea.app.activity;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBar;

import com.rocksea.app.fragment.CommonBaseInfoFragment;
import com.rocksea.app.fragment.PhotoFragment;

/**
 * @author Administrator
 * @date 2017/10/27
 */

public class HighStrainActivity extends BaseShowActivity
{
    private static String[] TITLES = {"基本信息","现场照片"};
    @Override
    public void initData() {
        String baseInfoId = infos[2];
        mBundle = new Bundle();
        mBundle.putString(BaseShowActivity.BASEINFOID_KEY,baseInfoId);
        mBundle.putString(BaseShowActivity.PLAN_NUM_KEY,infos[0]);
        mBundle.putString(BaseShowActivity.PLIE_NO_KEY,infos[1]);
    }
    @Override
    protected void actionBarTitle(ActionBar actionBar)
    {
        actionBar.setTitle(String.format("%s-高应变信息",infos[1]));
    }
    @Override
    public void addFragment(ViewPager viewPager)
    {
        CommonFragmentAdapter lowStrainFragmentAdapter = new CommonFragmentAdapter(getSupportFragmentManager());
        viewPager.setAdapter(lowStrainFragmentAdapter);
    }

    private class CommonFragmentAdapter extends FragmentPagerAdapter {
        private CommonFragmentAdapter(FragmentManager fm)
        {
            super(fm);
        }
        @Override
        public Fragment getItem(int i) {
            switch (i) {
                case 0:
                    return CommonBaseInfoFragment.newInstance(mBundle);
                case 1:
                    return PhotoFragment.newInstance(mBundle);
                default:
                    return null;
            }
        }
        @Override
        public int getCount() {
            return TITLES.length;
        }
        @Override
        public CharSequence getPageTitle(int position) {
            return TITLES[position];
        }

    }


}
